import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import {
    customApiResolver,
    customHookResolver,
    customStoreResolver
} from "./internal/custom-resolver";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import CustomComponent from "./src/components/resolvers";
import * as path from "path";

export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            dts: "typings/auto-imports/auto-imports.d.ts",
            imports: ["vue", "vue-router"],
            resolvers: [
                customStoreResolver(),
                customApiResolver(),
                customHookResolver()
            ],
            eslintrc: {
                enabled: false,
                filepath: "./.eslintrc-auto-import.json",
                globalsPropValue: true
            },
        }),
        Components({
            dts: "typings/auto-imports/components.d.ts",
            resolvers: [
                ElementPlusResolver(),
                CustomComponent({ importStyle: "less" })
            ]
        }),
    ],
    build: {
        minify: "terser",
        terserOptions: {
            compress: {
                drop_console: true,
                drop_debugger: true
            }
        }
    },
    resolve: {
        alias: {
            "@": path.resolve(__dirname, "src")
        }
    }
});
